#include <ctime>
#include <unistd.h>
#include "ThreadPool.hpp"
#include "Task.hpp"

int main()
{
    srand(time(nullptr));
    int len = oper.size();
    //std::cout<<"snowdragon"<<std::endl;
    ThreadPool<Task>::GetInstance()->Start();       //记得调用Start函数，否则线程不会被创建和运行相应的任务
    //std::cout<<"snowdragon"<<std::endl;
    while(true)
    {
        int data1 = rand() % 10 + 1;
        int data2 = rand() % 10;
        //int data2 = 0;
        char op = oper[rand() % len];
        usleep(1000);
        Task t(data1, data2, op);
        //std::cout<<"snowdragon"<<std::endl;

        ThreadPool<Task>::GetInstance()->Push(t);
        //std::cout<<"snowdragon"<<std::endl;

        std::cout << "main thread push a task" << std::endl;
        //sleep(1);
        usleep(5000);
    }

    return 0;
}